import datetime
from typing import TypeVar

from pydantic import BaseModel, root_validator

from app.database.models import Proxy

T = TypeVar("T", bound=dict)


class OrderModel(BaseModel):
    type: str
    user_id: int = None
    proxies: list[Proxy] = None
    country_id: int = None
    provider_id: int = None
    category_id: int = None
    site_id: int = None
    summ: float = None
    period: str = None
    expiring_on: datetime.datetime = None

    class Config:
        arbitrary_types_allowed = True

    # @root_validator
    # def check_len_of_proxies(cls, values: T) -> T:
    #
    #     proxies = values.get("proxies")
    #
    #     if len(proxies) <= 0:
    #         raise ValueError("Длина списка прокси меньше или равна 0.")
    #
    #     return values
